home *** CD-ROM | disk | FTP | other *** search
/ Freaks Macintosh Archive / Freaks Macintosh Archive.bin / Freaks Macintosh Archives / Ham⁄GPS / SoftKiss.src.1.8 Folder / SoftKiss.src.1.8 / core / sfk_core_some_macs.c < prev    next >
Text File  |  1993-03-12  |  3KB  |  142 lines

  1. /*
  2.  * SoftKiss code that runs on some macs and not others
  3.  * by Aaron Wohl / N3LIW (aw0g+@andrew.cmu.edu) jul 1990
  4.  * 6393 Penn Ave #303
  5.  * Pittsburgh PA, 15206
  6.  * work: (412)-268-5032
  7.  * home: (412)-731-6159
  8.  */
  9.  
  10. #include "sfk_core_some_macs.h"
  11. #include <OSChecks.h>
  12. #include <Traps.h>
  13. #include <Power.h>
  14. #include <GestaltEqu.h>
  15. /*
  16.  * traps that are too new to be in Traps.h
  17.  */
  18. #define _SerialPowerX     (0xA685)
  19. #define _IdleStateX     (0xA485)
  20. #define _CacheFlushTrap    (0xA0BD)
  21.  
  22. /*
  23.  * is the scc hardware available
  24.  */
  25. int have_scc(void)
  26. {
  27.   long response;
  28.   int iErr=Gestalt(gestaltHardwareAttr,&response);
  29.   if(iErr!=0)
  30.       return TRUE;    /*can't tell assume yes*/
  31.   return ((response&(1<<gestaltHasSCC))!=0);
  32. }
  33.  
  34. /*
  35.  * tell if the power manager is implemented on this machine
  36.  */
  37. int serial_power_implemented(void)
  38. {
  39.   return TrapAvailable(_SerialPowerX);
  40. }
  41.  
  42. /*
  43.  * tell if the sleep/speed manager is implemented on this machine
  44.  */
  45. int sleep_state_implemented(void)
  46. {
  47.   return TrapAvailable(_IdleStateX);
  48. }
  49.  
  50. /*
  51.  * tell if the virtual memory manager is implemented on this machine
  52.  */
  53. int is_vm_manager_present(void)
  54. {
  55.   return TrapAvailable(_MemoryDispatch);
  56. }
  57.  
  58. /*
  59.  * tell if the code/data cache  manager is implemented on this machine
  60.  */
  61. int is_cache_manager_present(void)
  62. {
  63.   return TrapAvailable(_CacheFlushTrap);
  64. }
  65.  
  66. /*
  67.  * power up scc and select internal or external modem
  68.  */
  69. void power_up_port(int pnum,int ignore_modem)
  70. {
  71.     if(sleep_state_implemented())
  72.           DisableIdle();
  73.       if(serial_power_implemented()) {
  74.         if(pnum==0)
  75.             BOn();
  76.         else if (ignore_modem)
  77.               AOnIgnoreModem();
  78.           else
  79.               AOn();
  80.     }
  81. }
  82.  
  83. /*
  84.  * power down scc and modem
  85.  */
  86. void power_down_port(int pnum)
  87. {
  88.   if(serial_power_implemented()) {
  89.     if(pnum==0)
  90.       AOff();
  91.     else
  92.         BOff();
  93.   }
  94.   if(sleep_state_implemented())
  95.       EnableIdle();
  96. }
  97.  
  98. /*
  99.  * Lock something in memory if virtual memory is running
  100.  * return TRUE iff it was locked
  101.  */
  102. int sfk_lock_if_vm_implimented(void *something_to_lock,long size)
  103. {
  104. // get vm working some day ??
  105. // if(!is_vm_manager_present())
  106.       return FALSE;
  107.   LockMemory(something_to_lock,size);
  108.   return TRUE;
  109. }
  110.  
  111. /*
  112.  * unlocked the passed block to make it swapable
  113.  */
  114. void sfk_unlock_if_vm_implimented(void *something_to_unlock,long size)
  115. {
  116. //  if(is_vm_manager_present())
  117. //    UnlockMemory(something_to_unlock,size);
  118. }
  119.  
  120. /*
  121.  * some macs have a data and code cache that needs to be flushed
  122.  * after patching code
  123.  */
  124. void sfk_some_flush(void)
  125. {
  126.   FlushCache();
  127. }
  128.  
  129. /*
  130.  * return the time manager version
  131.  */
  132. int time_manager_version(void)
  133. {
  134.   long response;
  135.   int iErr=Gestalt(gestaltTimeMgrVersion,&response);
  136.   if(iErr!=0)
  137.       return 1;    /*can't tell assume one version 1*/
  138.   return response;
  139. }
  140.  
  141.  
  142.